#include <bits/stdc++.h>
// 2025/01/16
// tag: 
using namespace std;

int n;
string s[20001];
unordered_map<unsigned long long, int> hayek;
unsigned long long h[20001];

inline unsigned long long Hash(int p, int a, int j){
    unsigned long long ans = 0;
    for (int i = a; i < j; i++)
        ans = ans * 27 + s[p][i] - 'a' + 1;
    return ans;
}

void help(int p){
    unordered_set<unsigned long long> have;
    for (int i = 0; i < s[p].size(); i++)
        for (int j = i; j <= s[p].size(); j++)
            have.insert(Hash(p, i, j));
    for (auto x: have)
        hayek[x]++;
}

signed main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> s[i], h[i] = Hash(i, 0, s[i].size());
    for (int i = 1; i <= n; i++)
        help(i);
    long long ans = 0;
    for (int i = 1; i <= n; i++)
        ans += hayek[h[i]] - 1;
    cout << ans << endl;
    return 0;
}